package com.google.android.apps.wakemewhere.ui;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Paint.Style;

import com.google.android.apps.wakemewhere.R;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;


public class RadiusOverlay extends Overlay {

	private GeoPoint geopoint;
	private int radius;

	public RadiusOverlay(GeoPoint point, int radiusInPixels) {
		geopoint = point;
		radius = radiusInPixels;
	}

	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow) {

		Projection projection = mapView.getProjection();
		Point point = new Point();
		projection.toPixels(geopoint, point);

		Paint circlePaint = new Paint();
		circlePaint.setStrokeWidth(1);
		circlePaint.setAntiAlias(true);

		// Draw the outer circle
		circlePaint.setARGB(255, 100, 156, 210);
		circlePaint.setStyle(Style.STROKE);
		canvas.drawCircle(point.x, point.y, radius + 1, circlePaint);

		// Fill the circle
		circlePaint.setARGB(100, 100, 156, 210);
		circlePaint.setStyle(Style.FILL_AND_STROKE);
		canvas.drawCircle(point.x, point.y, radius, circlePaint);
		
		Bitmap bmp = BitmapFactory.decodeResource(
                mapView.getResources(), R.drawable.red_pushpin);  
		
		Paint pushpinPaint = new Paint(Paint.ANTI_ALIAS_FLAG|Paint.FILTER_BITMAP_FLAG);
		canvas.drawBitmap(bmp, point.x-12, point.y-42, pushpinPaint);         
	}
	
}